package me.zhengjie.inter.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.business.domain.Pj;
import me.zhengjie.business.service.AdlXmxxService;
import me.zhengjie.business.service.PjService;
import me.zhengjie.inter.service.MpAdlZhsqService;
import me.zhengjie.inter.service.MpPjService;
import me.zhengjie.utils.PageUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author xiahongbo
 * @date 2022-08-28
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "移动端评价表")
@RequestMapping("/mp/pj")
public class MpPjController {

    private final MpPjService mpPjService;
    private final PjService pjService;

    @GetMapping
    @ApiOperation("根据订单ID查询一些信息")
    public ResponseEntity<Object> queryInfo(String orderId) {
        return new ResponseEntity<>(PageUtil.toMpContent(mpPjService.queryInfo(orderId)), HttpStatus.OK);
    }

    @PostMapping
    @Log("新增评价")
    @ApiOperation("新增评价")
    public ResponseEntity<Object> createPj(@Validated @RequestBody Pj resources){
        return new ResponseEntity<>(PageUtil.toMpContent(pjService.create(resources)),HttpStatus.CREATED);
    }
}
